//
//  GroupMessageDataBase.h
//  AAIM
//
//  Created by awh on 2019/12/23.
//  Copyright © 2019年 AAIM. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface GroupMessageDataBase : NSObject
+ (instancetype)shareGroupMessageDataBase;

- (void)creatChatTable;

// 插入数据
- (void)insertMessage:(BTMessageModel *)msg;

// 批量插入数据
- (void)insertMessagArray:(NSArray<BTMessageModel *> *)messages;

// 根据时间戳修改消息的发送状态
- (void)updateMessage:(BTMessageModel *)msg statusTo:(MessageStatus)status;

// 根据时间戳删除聊天记录
- (void)deleteMessage:(BTMessageModel *)msg;

// 根据uid更新头像
- (void)updateAvatarWithUid:(NSInteger)uid avatar:(NSString *)avatar;

// 根据uid更新昵称
- (void)updateUsernameWithUid:(NSInteger)uid username:(NSString *)username;

// 清空群聊记录
- (void)clearAllMessageWithGroupId:(NSInteger)groupId;

// 清除时间戳之前的聊天记录
- (void)deleteMessageBeforeTimestamp:(long long)timestamp;

// 清空所有群的聊天记录
- (void)clearAllMessageWithAllGroups;

// 根据groupId和聊天内容模糊搜索
- (NSArray<BTMessageModel *> *)queryMessagesWithGroupId:(NSInteger)groupId byContent:(NSString *)content;

//查询所有群
- (NSArray<BTMessageModel *> *)queryGroupMessagesWithKeyWord:(NSString *) keyWord;

// 根据groupId查询一条最新记录
- (BTMessageModel *)recentlyMessageWithGroupId:(NSInteger)groupId;

// 查找groupId的所有消息记录
- (NSArray<BTMessageModel *> *)queryAllMessagesWithGroupId:(NSInteger)groupId;

// 分页加载，每页20条
- (NSArray *)queryMessagesWithGroupId:(NSInteger)groupId toTimestamp:(long long) toTimestamp;

// 加载最新的count条数据
- (NSArray *)queryMessagesWithGroupId:(NSInteger)groupId count:(NSInteger)count;

@end

NS_ASSUME_NONNULL_END
